package com.kongjs.online.preview.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class  WebMvcConfiguration implements WebMvcConfigurer {
    @Autowired
    private OnlinePreviewConfiguration onlinePreviewConfiguration;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
                .addResourceHandler("/**")
                .addResourceLocations(
                        "classpath:/META-INF/resources/",
                        "classpath:/resources/",
                        "classpath:/static/",
                        "classpath:/public/",
                        "classpath:/pdfjs/pdfjs-3.1.81-legacy-dist/",
                        "classpath:/pdfjs/pdfjs-3.1.81-legacy-dist/web/"
                );
        registry
                .addResourceHandler(onlinePreviewConfiguration.getOnlinePreviewFileUri()+"**")
                .addResourceLocations("file:"+onlinePreviewConfiguration.getOnlinePreviewFileDir());
    }

}